package com.jd.controller;

import com.jd.entity.WxPayConfig;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WechatMpConfig {


        @Bean
        public WxMpService wxMpService(){
            WxMpService wxMpService = new WxMpServiceImpl();
            wxMpService.setWxMpConfigStorage(wxMpConfigStorage());
            return wxMpService;
        }

        @Bean
        public WxMpConfigStorage wxMpConfigStorage(){
        	WxPayConfig wxPayConfig = new WxPayConfig();
            WxMpInMemoryConfigStorage wxMpConfigStorage = new WxMpInMemoryConfigStorage();
            wxMpConfigStorage.setAppId(wxPayConfig.getAppID());
            wxMpConfigStorage.setSecret("d8b3a147d65a2a4f5653e579e6906b8f");
            return wxMpConfigStorage;
        }

}
